$(function () {
    $.ajax({
        url:"http://localhost:8085/sso/isLogin",
        dataType:"jsonp",//解决跨域问题
        jsonpCallback:"info",
        success:function (data) {
            if (data) {
                //var user=eval("("+data+")")
                var user=JSON.parse(data)
                $("#showUser").html("您好，<span id='nickName'>"+user.nickName+"</span> 欢迎来到宅客微购  <a href='http://localhost:8085/sso/logout'>注销</a>")
            }else {
                $("#showUser").html("<span type='hidden' id='nickName'></span> <a onclick='tologin()' href='javascript:void(0)'>登陆</a>  <a href='http://localhost:8085/toRegister'>注册</a>")
            }

        }
    })
})

function tologin() {
    var url = location.href;
    location.href="http://localhost:8085/toLogin?returnUrl="+url
}